#ifndef __MUTEXLOCK_H__
#define __MUTEXLOCK_H__

#include "NoCopy.hpp"
#include <pthread.h>

namespace cdm{

class MutexLock:public NoCopy{

public:
    MutexLock();
    ~MutexLock();
    
    void lock();
    void unlock();
    pthread_mutex_t* getMutexPtr();

private:
    pthread_mutex_t _mutex;

};

class MutexLockGuard{
    
public:
    MutexLockGuard(MutexLock &mutex)
    :_mutexLock(mutex){
        _mutexLock.lock();
    };

    ~MutexLockGuard(){
        _mutexLock.unlock();
    }

private:
    MutexLock& _mutexLock;
};

}//end of namespace

#endif

